$(function(){
    obj.init();
});

var obj = new JsFun();
function JsFun(){
    'use strict';
    return {
        dataGrid: null,
        id: null,
        init: function () {
            window.top.swal.resetDefaults();
            // this.id = xhTool.getQuery('id');
            this.dataGrid = new xhDataGrid($('#list'), 'User/getUserConfigureData');
            this.dataGrid.parseToolbar().init().activeButton(['bt_list_del']);
            this.listener();
            this.funObj().bindDataGridEvent();
        },
        listener: function () {
            var $this = this;
            $("#bt_list_add").click(function () {
                window.top.xhTop.showModal({
                    title:'用户配置',
                    content: '<iframe src="'+baseUrl+'User/storeUserConfigureForm" id="userConfigure" name="userConfigure" style="width: 300px;;border-style: none;padding: 0px;height:180px;"  scrolling="yes"  ></iframe>',
                    width:675,
                    backClose:false,
                    button: '保存'
                });
            });
            $("#bt_list_del").click(function () {
                if(xhExtra.buttonDisabled($(this))){
                    return false;
                }
                var id = $this.dataGrid.getSelectValues('id');
                if (id.length <= 0) {
                    window.top.xhTop.showError('未选中记录！');
                    return false;
                }
                if (id.length > 1) {
                    window.top.xhTop.showError('最多选择一条记录！');
                    return false;
                }
                xhExtra.askChangeStatus('User/delUserConfigureData', {id: id}, $this.dataGrid);
            });
        },
        funObj: function(){
            var $this = this;
            return {
                bindDataGridEvent: function () {
                    $this.dataGrid.onDblClickRow = function (rowIndex, rowData) {
                        console.log(rowData.id);
                        window.top.xhTop.showModal({
                            title:'用户配置',
                            content: '<iframe src="'+baseUrl+'User/storeUserConfigureForm?id='+rowData.id+'"  style="width: 300px;;border-style: none;padding: 0px;height:180px;"  scrolling="yes"  ></iframe>',
                            width:675,
                            backClose:false,
                            button: '保存'
                        });
                    };
                },
            }
        }
    }
}

